home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / SDLA_FR.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  16KB  |  423 lines

  1. /*****************************************************************************
  2. * sdla_fr.h    Sangoma frame relay firmware API definitions.
  3. *
  4. * Author:    Jaspreet Singh  <jaspreet@sangoma.com>
  5. *        Gene Kozin    <74604.152@compuserve.com>
  6. *
  7. * Copyright:    (c) 1995-1996 Sangoma Technologies Inc.
  8. *
  9. *        This program is free software; you can redistribute it and/or
  10. *        modify it under the terms of the GNU General Public License
  11. *        as published by the Free Software Foundation; either version
  12. *        2 of the License, or (at your option) any later version.
  13. * ============================================================================
  14. * Oct 12, 1997    Jaspreet Singh    Added FR_READ_DLCI_IB_MAPPING
  15. * Jul 21, 1997     Jaspreet Singh    Changed FRRES_TOO_LONG and FRRES_TOO_MANY to 
  16. *                0x05 and 0x06 respectively.
  17. * Dec 23, 1996    Gene Kozin    v2.0
  18. * Apr 29, 1996    Gene Kozin    v1.0 (merged version S502 & S508 definitions).
  19. * Sep 26, 1995    Gene Kozin    Initial version.
  20. *****************************************************************************/
  21. #ifndef    _SDLA_FR_H
  22. #define    _SDLA_FR_H
  23.  
  24. /*----------------------------------------------------------------------------
  25.  * Notes:
  26.  * ------
  27.  * 1. All structures defined in this file are byte-alined.  To ensure
  28.  *    portability of this code between different platforms and compilers, one
  29.  *    of the following defines must be defined before including this file:
  30.  *
  31.  *    Compiler    Platform    Define        Use option
  32.  *    --------    --------    ------        ----------
  33.  *    GNU C        Linux        _GNUC_        -
  34.  *    Microsoft C    DOS/Windows    _MSC_        -
  35.  */
  36.  
  37. #ifdef        _GNUC_
  38. #  ifndef    PACKED
  39. #    define    PACKED    __attribute__((packed))
  40. #  endif    /* PACKED */
  41. #else
  42. #  define    PACKED
  43. #endif
  44. #ifdef        _MSC_
  45. #  pragma    pack(1)
  46. #endif
  47.  
  48. /* Adapter memory layout */
  49. #define    FR_MB_VECTOR    0xE000    /* mailbox window vector */
  50. #define    FR502_RX_VECTOR    0xA000    /* S502 direct receive window vector */
  51. #define    FR502_MBOX_OFFS    0xF60    /* S502 mailbox offset */
  52. #define    FR508_MBOX_OFFS    0    /* S508 mailbox offset */
  53. #define    FR502_FLAG_OFFS    0x1FF0    /* S502 status flags offset */
  54. #define    FR508_FLAG_OFFS    0x1000    /* S508 status flags offset */
  55. #define    FR502_RXMB_OFFS    0x900    /* S502 direct receive mailbox offset */
  56. #define    FR508_TXBC_OFFS    0x1100    /* S508 Tx buffer info offset */
  57. #define    FR508_RXBC_OFFS    0x1120    /* S508 Rx buffer info offset */
  58.  
  59. /* Important constants */
  60. #define FR502_MAX_DATA    4096    /* maximum data buffer length */
  61. #define FR508_MAX_DATA    4080    /* maximum data buffer length */
  62.  
  63. /****** Data Structures *****************************************************/
  64.  
  65. /*----------------------------------------------------------------------------
  66.  * Frame relay command block.
  67.  */
  68. typedef struct fr_cmd
  69. {
  70.     unsigned char  command    PACKED;    /* command code */
  71.     unsigned short length    PACKED;    /* length of data buffer */
  72.     unsigned char  result    PACKED;    /* return code */
  73.     unsigned short dlci    PACKED;    /* DLCI number */
  74.     unsigned char  attr    PACKED;    /* FECN, BECN, DE and C/R bits */
  75.     unsigned short rxlost1    PACKED;    /* frames discarded at int. level */
  76.     unsigned long  rxlost2    PACKED;    /* frames discarded at app. level */
  77.     unsigned char  rsrv[2]    PACKED;    /* reserved for future use */
  78. } fr_cmd_t;
  79.  
  80. /* 'command' field defines */
  81. #define    FR_WRITE        0x01
  82. #define    FR_READ            0x02
  83. #define    FR_ISSUE_IS_FRAME    0x03
  84. #define FR_SET_CONFIG        0x10
  85. #define FR_READ_CONFIG        0x11
  86. #define FR_COMM_DISABLE        0x12
  87. #define FR_COMM_ENABLE        0x13
  88. #define FR_READ_STATUS        0x14
  89. #define FR_READ_STATISTICS    0x15
  90. #define FR_FLUSH_STATISTICS    0x16
  91. #define    FR_LIST_ACTIVE_DLCI    0x17
  92. #define FR_FLUSH_DATA_BUFFERS    0x18
  93. #define    FR_ADD_DLCI        0x20
  94. #define    FR_DELETE_DLCI        0x21
  95. #define    FR_ACTIVATE_DLCI    0x22
  96. #define    FR_DEACTIVATE_DLCI    0x22
  97. #define FR_READ_MODEM_STATUS    0x30
  98. #define FR_SET_MODEM_STATUS    0x31
  99. #define FR_READ_ERROR_STATS    0x32
  100. #define FR_FLUSH_ERROR_STATS    0x33
  101. #define FR_READ_DLCI_IB_MAPPING 0x34
  102. #define FR_READ_CODE_VERSION    0x40
  103. #define    FR_SET_INTR_MODE    0x50
  104. #define    FR_READ_INTR_MODE    0x51
  105.  
  106. /* 'result' field defines */
  107. #define FRRES_OK        0x00    /* command executed successfully */
  108. #define    FRRES_DISABLED        0x01    /* communications not enabled */
  109. #define    FRRES_INOPERATIVE    0x02    /* channel inoperative */
  110. #define    FRRES_DLCI_INACTIVE    0x03    /* DLCI is inactive */
  111. #define    FRRES_DLCI_INVALID    0x04    /* DLCI is not configured */
  112. #define    FRRES_TOO_LONG        0x05
  113. #define    FRRES_TOO_MANY        0x06
  114. #define    FRRES_CIR_OVERFLOW    0x07    /* Tx throughput has exceeded CIR */
  115. #define    FRRES_BUFFER_OVERFLOW    0x08
  116. #define    FRRES_MODEM_FAILURE    0x10    /* DCD and/or CTS dropped */
  117. #define    FRRES_CHANNEL_DOWN    0x11    /* channel became inoperative */
  118. #define    FRRES_CHANNEL_UP    0x12    /* channel became operative */
  119. #define    FRRES_DLCI_CHANGE    0x13    /* DLCI status (or number) changed */
  120. #define    FRRES_DLCI_MISMATCH    0x14
  121. #define    FRRES_INVALID_CMD    0x1F    /* invalid command */
  122.  
  123. /* 'attr' field defines */
  124. #define    FRATTR_
  125.  
  126. /*----------------------------------------------------------------------------
  127.  * Frame relay mailbox.
  128.  *    This structure is located at offset FR50?_MBOX_OFFS into FR_MB_VECTOR.
  129.  *    For S502 it is also located at offset FR502_RXMB_OFFS into
  130.  *    FR502_RX_VECTOR.
  131.  */
  132. typedef struct fr_mbox
  133. {
  134.     unsigned char opflag    PACKED;    /* 00h: execution flag */
  135.     fr_cmd_t cmd        PACKED;    /* 01h: command block */
  136.     unsigned char data[1]    PACKED;    /* 10h: variable length data buffer */
  137. } fr_mbox_t;
  138.  
  139. /*----------------------------------------------------------------------------
  140.  * S502 frame relay status flags.
  141.  *    This structure is located at offset FR502_FLAG_OFFS into FR_MB_VECTOR.
  142.  */
  143. typedef struct    fr502_flags
  144. {    
  145.     unsigned char rsrv1[1]    PACKED;    /* 00h: */
  146.     unsigned char tx_ready    PACKED;    /* 01h: Tx buffer available */
  147.     unsigned char rx_ready    PACKED;    /* 02h: Rx frame available */
  148.     unsigned char event    PACKED;    /* 03h: asynchronous event */
  149.     unsigned char mstatus    PACKED;    /* 04h: modem status */
  150.     unsigned char rsrv2[8]    PACKED;    /* 05h: */
  151.     unsigned char iflag    PACKED;    /* 0Dh: interrupt flag */
  152.     unsigned char imask    PACKED;    /* 0Eh: interrupt mask */
  153. } fr502_flags_t;
  154.  
  155. /*----------------------------------------------------------------------------
  156.  * S508 frame relay status flags.
  157.  *    This structure is located at offset FR508_FLAG_OFFS into FR_MB_VECTOR.
  158.  */
  159. typedef struct    fr508_flags
  160. {
  161.     unsigned char rsrv1[3]    PACKED;    /* 00h: reserved */
  162.     unsigned char event    PACKED;    /* 03h: asynchronous event */
  163.     unsigned char mstatus    PACKED;    /* 04h: modem status */
  164.     unsigned char rsrv2[11]    PACKED;    /* 05h: reserved */
  165.     unsigned char iflag    PACKED;    /* 10h: interrupt flag */
  166.     unsigned char imask    PACKED;    /* 11h: interrupt mask */
  167.     unsigned long tse_offs    PACKED;    /* 12h: Tx status element */
  168.     unsigned short dlci    PACKED; /* 16h: DLCI NUMBER */
  169. } fr508_flags_t;
  170.  
  171. /* 'event' field defines */
  172. #define    FR_EVENT_STATUS        0x01    /* channel status change ??? */
  173. #define    FR_EVENT_DLC_STATUS    0x02    /* DLC status change */
  174. #define    FR_EVENT_BAD_DLCI    0x04    /* FSR included wrong DLCI */
  175. #define    FR_EVENT_LINK_DOWN    0x40    /* DCD or CTS low */
  176.  
  177. /* 'mstatus' field defines */
  178. #define    FR_MDM_DCD        0x08    /* mdm_status: DCD */
  179. #define    FR_MDM_CTS        0x20    /* mdm_status: CTS */
  180.  
  181. /* 'iflag' & 'imask' fields defines */
  182. #define    FR_INTR_RXRDY        0x01    /* Rx ready */
  183. #define    FR_INTR_TXRDY        0x02    /* Tx ready */
  184. #define    FR_INTR_MODEM        0x04    /* modem status change (DCD, CTS) */
  185. #define    FR_INTR_READY        0x08    /* interface command completed */
  186. #define    FR_INTR_DLC        0x10    /* DLC status change */
  187. #define    FR_INTR_TIMER        0x20    /* millisecond timer */
  188.  
  189. /*----------------------------------------------------------------------------
  190.  * Receive Buffer Configuration Info. S508 only!
  191.  *    This structure is located at offset FR508_RXBC_OFFS into FR_MB_VECTOR.
  192.  */
  193. typedef struct    fr_buf_info
  194. {
  195.     unsigned short rse_num    PACKED;    /* 00h: number of status elements */
  196.     unsigned long rse_base    PACKED;    /* 02h: receive status array base */
  197.     unsigned long rse_next    PACKED;    /* 06h: next status element */
  198.     unsigned long buf_base    PACKED;    /* 0Ah: rotational buffer base */
  199.     unsigned short reserved    PACKED;    /* 0Eh:  */
  200.     unsigned long buf_top    PACKED;    /* 10h: rotational buffer top */
  201. } fr_buf_info_t;
  202.  
  203. /*----------------------------------------------------------------------------
  204.  * Buffer Status Element. S508 only!
  205.  *    Array of structures of this type is located at offset defined by the
  206.  *    'rse_base' field of the frBufInfo_t structure into absolute adapter
  207.  *    memory address space.
  208.  */
  209. typedef struct    fr_buf_ctl
  210. {
  211.     unsigned char flag    PACKED;    /* 00h: ready flag */
  212.     unsigned short length    PACKED;    /* 01h: frame length */
  213.     unsigned short dlci    PACKED;    /* 03h: DLCI */
  214.     unsigned char attr    PACKED;    /* 05h: FECN/BECN/DE/CR */
  215.     unsigned short tmstamp    PACKED;    /* 06h: time stamp */
  216.     unsigned short rsrv[2]    PACKED; /* 08h:  */
  217.     unsigned long offset    PACKED;    /* 0Ch: buffer absolute address */
  218. } fr_buf_ctl_t;
  219.  
  220. /*----------------------------------------------------------------------------
  221.  * Global Configuration Block. Passed to FR_SET_CONFIG command when dlci == 0.
  222.  */
  223. typedef struct    fr_conf
  224. {
  225.     unsigned short station    PACKED;    /* 00h: CPE/Node */
  226.     unsigned short options    PACKED;    /* 02h: configuration options */
  227.     unsigned short kbps    PACKED;    /* 04h: baud rate in kbps */
  228.     unsigned short port    PACKED;    /* 06h: RS-232/V.35 */
  229.     unsigned short mtu    PACKED;    /* 08h: max. transmit length */
  230.     unsigned short t391    PACKED;    /* 0Ah:  */
  231.     unsigned short t392    PACKED;    /* 0Ch:  */
  232.     unsigned short n391    PACKED;    /* 0Eh:  */
  233.     unsigned short n392    PACKED;    /* 10h:  */
  234.     unsigned short n393    PACKED;    /* 12h:  */
  235.     unsigned short cir_fwd    PACKED;    /* 14h:  */
  236.     unsigned short bc_fwd    PACKED;    /* 16h:  */
  237.     unsigned short be_fwd    PACKED;    /* 18h:  */
  238.     unsigned short cir_bwd    PACKED;    /* 1Ah:  */
  239.     unsigned short bc_bwd    PACKED;    /* 1Ch:  */
  240.     unsigned short be_bwd    PACKED;    /* 1Eh:  */
  241.     unsigned short dlci[0]    PACKED;    /* 20h:  */
  242. } fr_conf_t;
  243.  
  244. /* 'station_type' defines */
  245. #define    FRCFG_STATION_CPE    0
  246. #define    FRCFG_STATION_NODE    1
  247.  
  248. /* 'conf_flags' defines */
  249. #define    FRCFG_IGNORE_TX_CIR    0x0001
  250. #define    FRCFG_IGNORE_RX_CIR    0x0002
  251. #define    FRCFG_DONT_RETRANSMIT    0x0004
  252. #define    FRCFG_IGNORE_CBS    0x0008
  253. #define    FRCFG_THROUGHPUT    0x0010    /* enable throughput calculation */
  254. #define    FRCFG_DIRECT_RX        0x0080    /* enable direct receive buffer */
  255. #define    FRCFG_AUTO_CONFIG    0x8000    /* enable  auto DLCI configuration */
  256.  
  257. /* 'baud_rate' defines */
  258. #define    FRCFG_BAUD_1200        12
  259. #define    FRCFG_BAUD_2400        24
  260. #define    FRCFG_BAUD_4800        48
  261. #define    FRCFG_BAUD_9600        96
  262. #define    FRCFG_BAUD_19200    19
  263. #define    FRCFG_BAUD_38400    38
  264. #define    FRCFG_BAUD_56000    56
  265. #define    FRCFG_BAUD_64000    64
  266. #define    FRCFG_BAUD_128000    128
  267.  
  268. /* 'port_mode' defines */
  269. #define    FRCFG_MODE_EXT_CLK    0x0000
  270. #define    FRCFG_MODE_INT_CLK    0x0001
  271. #define    FRCFG_MODE_V35        0x0000    /* S508 only */
  272. #define    FRCFG_MODE_RS232    0x0002    /* S508 only */
  273.  
  274. /*----------------------------------------------------------------------------
  275.  * Channel configuration.
  276.  *    This structure is passed to the FR_SET_CONFIG command when dlci != 0.
  277.  */
  278. typedef struct    fr_dlc_conf
  279. {
  280.     unsigned short conf_flags    PACKED;    /* 00h: configuration bits */
  281.     unsigned short cir_fwd        PACKED;    /* 02h:  */
  282.     unsigned short bc_fwd        PACKED;    /* 04h:  */
  283.     unsigned short be_fwd        PACKED;    /* 06h:  */
  284.     unsigned short cir_bwd        PACKED;    /* 08h:  */
  285.     unsigned short bc_bwd        PACKED;    /* 0Ah:  */
  286.     unsigned short be_bwd        PACKED;    /* 0Ch:  */
  287. } fr_dlc_conf_t;
  288.  
  289. /*----------------------------------------------------------------------------
  290.  * S502 interrupt mode control block.
  291.  *    This structure is passed to the FR_SET_INTR_FLAGS and returned by the
  292.  *    FR_READ_INTR_FLAGS commands.
  293.  */
  294. typedef struct fr502_intr_ctl
  295. {
  296.     unsigned char mode    PACKED;    /* 00h: interrupt enable flags */
  297.     unsigned short tx_len    PACKED;    /* 01h: required Tx buffer size */
  298. } fr502_intr_ctl_t;
  299.  
  300. /*----------------------------------------------------------------------------
  301.  * S508 interrupt mode control block.
  302.  *    This structure is passed to the FR_SET_INTR_FLAGS and returned by the
  303.  *    FR_READ_INTR_FLAGS commands.
  304.  */
  305. typedef struct fr508_intr_ctl
  306. {
  307.     unsigned char mode    PACKED;    /* 00h: interrupt enable flags */
  308.     unsigned short tx_len    PACKED;    /* 01h: required Tx buffer size */
  309.     unsigned char irq    PACKED;    /* 03h: IRQ level to activate */
  310.     unsigned char flags    PACKED;    /* 04h: ?? */
  311.     unsigned short timeout    PACKED;    /* 05h: ms, for timer interrupt */
  312. } fr508_intr_ctl_t;
  313.  
  314. /*----------------------------------------------------------------------------
  315.  * Channel status.
  316.  *    This structure is returned by the FR_READ_STATUS command.
  317.  */
  318. typedef struct    fr_dlc_Status
  319. {
  320.     unsigned char status        PACKED;    /* 00h: link/DLCI status */
  321.     struct
  322.     {
  323.         unsigned short dlci    PACKED;    /* 01h: DLCI number */
  324.         unsigned char status    PACKED;    /* 03h: DLCI status */
  325.     } circuit[1]            PACKED;
  326. } fr_dlc_status_t;
  327.  
  328. /* 'status' defines */
  329. #define    FR_LINK_INOPER    0x00        /* for global status (DLCI == 0) */
  330. #define    FR_LINK_OPER    0x01
  331. #define    FR_DLCI_DELETED    0x01        /* for circuit status (DLCI != 0) */
  332. #define    FR_DLCI_ACTIVE    0x02
  333. #define    FR_DLCI_WAITING    0x04
  334. #define    FR_DLCI_NEW    0x08
  335. #define    FR_DLCI_REPORT    0x40
  336.  
  337. /*----------------------------------------------------------------------------
  338.  * Global Statistics Block.
  339.  *    This structure is returned by the FR_READ_STATISTICS command when
  340.  *    dcli == 0.
  341.  */
  342. typedef struct    fr_link_stat
  343. {
  344.     unsigned short rx_too_long    PACKED;    /* 00h:  */
  345.     unsigned short rx_dropped    PACKED;    /* 02h:  */
  346.     unsigned short rx_dropped2    PACKED;    /* 04h:  */
  347.     unsigned short rx_bad_dlci    PACKED;    /* 06h:  */
  348.     unsigned short rx_bad_format    PACKED;    /* 08h:  */
  349.     unsigned short retransmitted    PACKED;    /* 0Ah:  */
  350.     unsigned short cpe_tx_FSE    PACKED;    /* 0Ch:  */
  351.     unsigned short cpe_tx_LIV    PACKED;    /* 0Eh:  */
  352.     unsigned short cpe_rx_FSR    PACKED;    /* 10h:  */
  353.     unsigned short cpe_rx_LIV    PACKED;    /* 12h:  */
  354.     unsigned short node_rx_FSE    PACKED;    /* 14h:  */
  355.     unsigned short node_rx_LIV    PACKED;    /* 16h:  */
  356.     unsigned short node_tx_FSR    PACKED;    /* 18h:  */
  357.     unsigned short node_tx_LIV    PACKED;    /* 1Ah:  */
  358.     unsigned short rx_ISF_err    PACKED;    /* 1Ch:  */
  359.     unsigned short rx_unsolicited    PACKED;    /* 1Eh:  */
  360.     unsigned short rx_SSN_err    PACKED;    /* 20h:  */
  361.     unsigned short rx_RSN_err    PACKED;    /* 22h:  */
  362.     unsigned short T391_timeouts    PACKED;    /* 24h:  */
  363.     unsigned short T392_timeouts    PACKED;    /* 26h:  */
  364.     unsigned short N392_reached    PACKED;    /* 28h:  */
  365.     unsigned short cpe_SSN_RSN    PACKED;    /* 2Ah:  */
  366.     unsigned short current_SSN    PACKED;    /* 2Ch:  */
  367.     unsigned short current_RSN    PACKED;    /* 2Eh:  */
  368.     unsigned short curreny_T391    PACKED;    /* 30h:  */
  369.     unsigned short current_T392    PACKED;    /* 32h:  */
  370.     unsigned short current_N392    PACKED;    /* 34h:  */
  371.     unsigned short current_N393    PACKED;    /* 36h:  */
  372. } fr_link_stat_t;
  373.  
  374. /*----------------------------------------------------------------------------
  375.  * DLCI statistics.
  376.  *    This structure is returned by the FR_READ_STATISTICS command when
  377.  *    dlci != 0.
  378.  */
  379. typedef struct    fr_dlci_stat
  380. {
  381.     unsigned long tx_frames        PACKED;    /* 00h:  */
  382.     unsigned long tx_bytes        PACKED;    /* 04h:  */
  383.     unsigned long rx_frames        PACKED;    /* 08h:  */
  384.     unsigned long rx_bytes        PACKED;    /* 0Ch:  */
  385.     unsigned long rx_dropped    PACKED;    /* 10h:  */
  386.     unsigned long rx_inactive    PACKED;    /* 14h:  */
  387.     unsigned long rx_exceed_CIR    PACKED;    /* 18h:  */
  388.     unsigned long rx_DE_set        PACKED;    /* 1Ch:  */
  389.     unsigned long tx_throughput    PACKED;    /* 20h:  */
  390.     unsigned long tx_calc_timer    PACKED;    /* 24h:  */
  391.     unsigned long rx_throughput    PACKED;    /* 28h:  */
  392.     unsigned long rx_calc_timer    PACKED;    /* 2Ch:  */
  393. } fr_dlci_stat_t;
  394.  
  395. /*----------------------------------------------------------------------------
  396.  * Communications error statistics.
  397.  *    This structure is returned by the FR_READ_ERROR_STATS command.
  398.  */
  399. typedef struct    fr_comm_stat
  400. {
  401.     unsigned char rx_overruns    PACKED;    /* 00h:  */
  402.     unsigned char rx_bad_crc    PACKED;    /* 01h:  */
  403.     unsigned char rx_aborts        PACKED;    /* 02h:  */
  404.     unsigned char rx_too_long    PACKED;    /* 03h:  */
  405.     unsigned char tx_aborts        PACKED;    /* 04h:  */
  406.     unsigned char tx_underruns    PACKED;    /* 05h:  */
  407.     unsigned char tx_missed_undr    PACKED;    /* 06h:  */
  408.     unsigned char dcd_dropped    PACKED;    /* 07h:  */
  409.     unsigned char cts_dropped    PACKED;    /* 08h:  */
  410. } fr_comm_stat_t;
  411.  
  412. /*----------------------------------------------------------------------------
  413.  * Defines for the FR_ISSUE_IS_FRAME command.
  414.  */
  415. #define    FR_ISF_LVE    2        /* issue Link Verification Enquiry */
  416. #define    FR_ISF_FSE    3        /* issue Full Status Enquiry */
  417.  
  418. #ifdef        _MSC_
  419. #  pragma    pack()
  420. #endif
  421. #endif    /* _SDLA_FR_H */
  422.  
  423.